﻿#ifndef JRUNNABLE_H
#define JRUNNABLE_H

#include "jthreadpool_global.h"

/**
 * @brief The JRunnable class
 */
class JTHREADPOOL_EXPORT JRunnable
{
    int ref;
    friend class JThreadPool;
    friend class JThreadPoolThread;
    friend class JThreadPoolPrivate;
public:

    /**
     * @brief run
     */
    virtual void run() = 0;

    /**
     * @brief JRunnable
     */
    JRunnable() : ref(0) { }
    virtual ~JRunnable() { }

    /**
     * @brief autoDelete
     * @return
     */
    bool autoDelete() const { return ref != -1; }

    /**
     * @brief setAutoDelete
     * @param _autoDelete
     */
    void setAutoDelete(bool _autoDelete) { ref = _autoDelete ? 0 : -1; }
};

#endif  // JRUNNABLE_H
